<template>
  <div class="app-container">
    <el-card class="search-card">
      <el-row :gutter="20" style="font-size: 14px">
        <el-col :span="6"> 昨日消费总金额:{{ Detail.yesterdayOrderCount }}元 </el-col>
        <el-col :span="6" v-if="Detail.yestdayCountNum"> 昨日消费总笔数:{{ Detail.yestdayCountNum }}笔 </el-col>
        <el-col :span="6"> 今日消费总金额:{{ Detail.todayOrderCount }}元 </el-col>
        <el-col :span="6"v-if="Detail.todayCountNum"> 今日消费总笔数:{{ Detail.todayCountNum }}笔 </el-col>
      </el-row>
    </el-card>

    <el-card class="table-card">
      <el-table v-loading="loading" :data="flowList">
        <el-table-column label="商户名称" align="center" prop="merchantName" />
        <el-table-column label="设备名称" align="center" prop="deviceName" />
        <el-table-column label="设备SN码" align="center" prop="snCode" />
        <el-table-column label="昨日消费金额(元)" align="center" prop="yestdayConsumption" />
        <el-table-column label="昨日消费笔数(笔)" align="center" prop="yestdayCountNum" />
        <el-table-column label="今日消费金额(元)" align="center" prop="todayConsumption" />
        <el-table-column label="今日消费笔数(笔)" align="center" prop="todayCountNum" />
      </el-table>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-card>
  </div>
</template>

<script>
import { countSupermarketList, machineSupermarketList } from "@/api/order/merchant";

export default {
  name: "Flow",
  dicts: ["order_status", "operation_type", "payment_method"],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 交易流水表格数据
      flowList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      tk_open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      Detail: {
        todayOrderCount: "0.00",
        yesterdayOrderCount: "0.00",
      },
    };
  },
  created() {
    this.getList();
    this.countSupermarketListFun();
  },
  
  activated() {
    this.$forceUpdate();
  },
  methods: {
    countSupermarketListFun() {
      countSupermarketList().then((response) => {
        console.log("response", response);
        if (response.code == 200) {
          this.Detail = {
            todayOrderCount: response.data.todayOrderCount,
            yesterdayOrderCount: response.data.yesterdayOrderCount,
            todayCountNum: response.data.todayCountNum,
            yestdayCountNum: response.data.yestdayCountNum,
          };
        }
      });
    },
    /** 查询交易流水列表 */
    getList() {
      this.loading = true;
      machineSupermarketList(this.queryParams).then((response) => {
        this.flowList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
};
</script>
